import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router,Route,Link,Switch,Redirect} from 'react-router-dom';
import Layout from 'component/layout/index.jsx';
//页面
import Home from 'page/home/index.jsx';
import Login from 'page/login/index.jsx';
import ErrorPage from 'page/error/index.jsx';
import UserList from 'page/user/index.jsx';
import ProductRouter from 'page/product/router.jsx';
import OrderRouter from 'page/order/router.jsx';

class App extends React.Component{

  render(){
      let LayOutRoute =(
          <Layout>
          <Switch>
              <Route exact path="/" component={Home}/>
              <Route  path="/product" component={ProductRouter}/>
              <Route  path="/category" component={ProductRouter}/>
              <Route  path="/order" component={OrderRouter}/>
              <Route  path="/user/index" component={UserList}/>
              <Redirect exact  from="/user" to='/user/index'/>
              <Route component={ErrorPage}/>
          </Switch>
      </Layout>
    );
    return(
     <Router>
       <Switch>
              <Route exact path="/login" component={Login}/>
              <Route path="/" render={props=>LayOutRoute}/>
        </Switch>
     </Router>
    );
  }
}
ReactDOM.render(
  <App/>,  
  document.getElementById('app')
);
